<template>
	<view class="u-page">
		<view class="header">
		</view>
		<view class="content">
			<view class="projectList">
				<view class="label">员工权限管理</view>
				<block v-for="(item, index) in lists" :key="index" v-if="lists.length>0">
					<view class="lists">
						<view class="filename">
							<image src="../../static/icon/invem.png" mode=""></image>
						</view>
						<view class="list_contnet">
							<view class="projecttitle">{{item.nickname}}</view>
						</view>
						<view class="chakan" v-if="item.storeExamine == '0'">
							<view class="shenhe">审核</view>

							<switch @change="switch1Change(item.uid,'1')" style="transform:scale(0.7)" />
						</view>
						<view class="chakan" v-if="item.storeExamine =='1'">
							<view class="shenhe">审核</view>
							<switch checked @change="switch1Change(item.uid,'0')" style="transform:scale(0.7)" />
						</view>

					</view>
				</block>
				
				<view class="nodData" v-else>
					暂无数据
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				pid: '',
				lists: [],
			}
		},
		onLoad(data) {
			this.pid = data.id
			this.usersList();
		},
		methods: {
			async switch1Change(row, e) {

				const users = await this.GQL({
					"operationName": "updateSlUserByUid",
					"query": "mutation updateSlUserByUid($input: UpdateSlUserByUidInput!) { updateSlUserByUid(input: $input) { slUser { uid } } }",
					"variables": {
						"input": {
							"uid": row,
							"slUserPatch": {
								"storeExamine": e
							}
						}
					}
				})
				if (users.data.updateSlUserByUid.slUser.nodes != '') {

					this.usersList();
				}
			},
			goback() {
				uni.navigateBack({
					delta: 1
				})
			},
			async usersList() {
				const users = await this.GQL({
					"operationName": "allSlUsers",
					"query": "query allSlUsers($filter: SlUserFilter) { allSlUsers(filter:$filter) { nodes { nickname uid username phone jurisdiction isStore projectPid storeExamine } } }",
					"variables": {
						"filter": {
							"projectPid": {
								"equalTo": this.pid
							},
							"isStore": {
								'equalTo': '1'
							},
							"jurisdiction": {
								'equalTo': "3"
							}
						}
					}
				})
				// console.log('111',users);
				if (users.data.allSlUsers.nodes != '') {

					this.lists = users.data.allSlUsers.nodes

				}

			},


		}
	}
</script>

<style lang="scss">
	.nodData {
		height: 60vh;
		// font-weight: 600;
		background-color: #FFFFFF;
		color: #aaaaaa;
		border-radius: 5px;
		box-shadow: 1px -2px 10px 6px rgba(0, 0, 0, 0.1);
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.u-page {
		background-color: #FBFCFE;
	}

	.header {
		width: 100%;
		height: 200px;
		/* color: #FFFFFF; */
		background: linear-gradient(#C7171E, #f0f2f5);
		/* 标准的语法 */

	}

	.content {
		position: relative;
		top: -200px;

		margin: 15px;

		.label {
			font-size: 16px;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 600;
			color: #161E3E;
			line-height: 16px;
			margin-bottom: 20px;
		}

		.projectList {
			background-color: #FFFFFF;
			border-radius: 5px;
			min-height: 500px;
			padding: 24px 16px;

			.lists {
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1px solid #D7D7D7;
				line-height: 44px;
			}

			.list_contnet {
				width: 180px;
				margin-left: 10px;
				flex: 1;
			}
			.filename{
				display: flex;
				align-items: center;
			}

			.projecttitle {
				font-size: 15px;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #161E3E;
			}

			.chakan {
				display: flex;
				justify-content: flex-end;
				text-align: right;

				.shenhe {
					font-size: 15px;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #767B8D;
				}

			}

			image {
				width: 22px;
				height: 22px;
			}

		}
	}
</style>
